import java.util.*;
import java.io.*;
class Node
{
int x;
int y;
public Node(int x, int y)
{
this.x = x;
this.y = y;
}
} 

public class Main1
{
    public static void main(String[] args) throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while((str = reader.readLine()) != null)
        {
            String[] arr = str.split(" ");
            int row = Integer.parseInt(arr[0]);
            int col = Integer.parseInt(arr[1]);
            //创建迷宫矩阵
            int[][] mat = new int[row][col];
            //读入迷宫数据
            for(int i = 0; i < row; ++i)
            {
                str = reader.readLine();
                 arr = str.split(" ");
            for(int j = 0; j < col; ++j)
            {
                mat[i][j] = Integer.parseInt(arr[j]);
            }
        } 
        //搜索最短路径
        ArrayList<Node> path = new ArrayList<>();
        ArrayList<Node> minPath = new ArrayList<>();
        int[][] book = new int[row][col];
        getMinPath(mat, row, col, 0, 0, book, path, minPath);
    //打印最短路径
        for(Node n : minPath)
        {
            System.out.println("(" + n.x + "," + n.y + ")");
        }
    }
} 
//mat: 迷宫矩阵, row, col
//x, y: 当前位置
//book: 标记矩阵，标记当前位置是否走过
//path: 保存当前路径的每一个位置
//minPath: 保存最短路径
public static void getMinPath(int[][] mat, int row, int col,
    int x, int y, int[][] book, ArrayList<Node> path, ArrayList<Node> minPath)
    {
        //判断(x,y): 是否越界，是否走过，是否有障碍
        if(x < 0 || x >= row || y < 0 || y >= col
        || book[x][y] == 1 || mat[x][y] == 1)
        return;
        //把当前位置存入路径中
        path.add(new Node(x,y));
        //标记当前位置
        book[x][y] = 1;
        //判断当前位置是否为出口
        if(x == row - 1 && y == col - 1)
        {
        //一条新的路径产生
        //判断是否为更短的路径
        if(minPath.isEmpty() || path.size() < minPath.size())
        {
        //更新更短路径
        minPath.clear();
        for(Node n : path)
        minPath.add(n);
        }
        } 
        //继续搜索(x,y)的上下左右四个方向
        getMinPath(mat, row, col, x + 1, y, book, path, minPath);
        getMinPath(mat, row, col, x - 1, y, book, path, minPath);
        getMinPath(mat, row, col, x, y - 1, book, path, minPath);
        getMinPath(mat, row, col, x, y + 1, book, path, minPath);
        //把当前位置从路径中删除，寻找新的路径
        path.remove(path.size() - 1);
        book[x][y] = 0;
    }
}